package com.tim.arc.groovy.base
/**集合
 * */

/*List；有序列表*/
def list=['a','b','c','c'];
println("list.size="+list.size())
println(list[0])

/*Map；键值对*/
def map=[name:'nana', age:31, city:"cq"];
map.put 'a','b'
println("map.size="+map.size())
println(map.name)

/*Set；使用java set*/
def set=new HashSet();
set.add(1)
set.add(1)
println("set.size="+set.size())
println(set.first())

/*遍历，each*/
list.each {print(it)} //默认迭代参数it，可省？
list.each {e->print(e)}

map.each {lt->println(lt)}

/*链式调用*/
list=[1,2,3,4,5]
def sum = list.findAll {lt-> lt % 2 == 0 }
        .collect {lt-> lt + 2 }
        .sum()
println(sum)